home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / archive / userbox / publicdomain / engclock_v7.0.lha / EngClock_v7.0 / EngClock7_Source / globals.h < prev    next >
C/C++ Source or Header  |  1996-05-19  |  10KB  |  392 lines

  1. /* Global gear for EngClock */
  2.  
  3.  
  4. /************* Includes ************/
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include <intuition/intuition.h>
  10. #include <dos/dos.h>
  11. #include <dos/dostags.h>
  12. #include <exec/devices.h>
  13. #include <exec/execbase.h>
  14. #include <exec/exec.h>
  15. #include <exec/memory.h>
  16. #include <devices/timer.h>
  17. #include <clib/intuition_protos.h>
  18. #include <libraries/diskfont.h>
  19. #include <clib/diskfont_protos.h>
  20. #include <graphics/scale.h>
  21. #include <clib/graphics_protos.h>
  22. #include <graphics/gfxbase.h>
  23. #include <clib/exec_protos.h>
  24. #include <clib/utility_protos.h>
  25. //#include <proto/timer.h>
  26. #include <clib/timer_protos.h>
  27. #include <pragmas/timer_pragmas.h>
  28. #include <utility/utility.h>
  29. #include <utility/date.h>
  30. #include <workbench/startup.h>
  31. #include <clib/dos_protos.h>
  32. #include <clib/gadtools_protos.h>
  33. #include <datatypes/pictureclass.h>
  34. #include <clib/commodities_protos.h>
  35.  
  36. /************** Defines ***************/
  37.  
  38. #define VERS 1  /* Current version of preferences file */
  39.  
  40. #define PREFS_FILE "s:EngClock.prefs"
  41. #define GUIDECOMMAND "Amigaguide Engclock.guide"
  42. #define ID "EngCPrefs"
  43.  
  44. /* Following for locale */
  45. #define ENGLISH 1
  46. #define FRENCH 2
  47. #define SPANISH 3
  48.  
  49. /******** Global Variables *********/
  50.  
  51. BPTR handle;             /* Used by all file-handing operations */
  52.  
  53. char tmp[50],tmp2[50],line1[200], line2[200];
  54.  
  55. char *engnums[60];
  56.  
  57. int memmins, memhours;
  58.  
  59. BOOL afternoon; /* TRUE = pm, FALSE = am */
  60.  
  61. /* Following for Locale */
  62. int language;
  63. BOOL locale=TRUE;
  64.  
  65. /****** Global Structures *******/
  66.  
  67. struct Screen *pubscreen=NULL; /* Public screen structure */
  68. char screen[200];                  /* Name of above */
  69. char *screenptr = NULL;
  70.  
  71. /* Quick assignment for fonts */
  72.  
  73. struct TextAttr font1=
  74. {
  75.   "topaz.font",
  76.   TOPAZ_EIGHTY,
  77.   (UBYTE)NULL,
  78.   FPF_ROMFONT
  79. };
  80.  
  81. struct Event {
  82.     BOOL used;
  83.     int type;    /* Type of event */
  84.     int hours;    /* Time of event */
  85.     int minutes;
  86.     int timecode;
  87.     char message[256];
  88.     int day;
  89.     int month;
  90.     int year;
  91.     BOOL enabledate;
  92.     int freq;
  93. };
  94.  
  95. struct {
  96. /* Prefs structure used for preferences file format */
  97.  
  98.    char header[10];  /* I.D. Header */
  99.    int vers;         /* Version of preferences file */
  100.    int x;            /* X dimension of window when saved */
  101.    int y;            /* Y dimension of window when saved */
  102.    int width;        /* Width of window when saved */
  103.    int height;       /* Height of window when saved */
  104.    int planguage;    /* Language selected (menu) when saved, low pri */
  105.    int just;         /* Justification of text, 0=Left, 1=Centre */
  106.    short date;       /* Display date?, 0 = No, 1=Yes */
  107.    short wtf;         /* Window to front? */
  108.    int time_col[8];
  109.    int date_col[8];
  110.    short autoadjust;       /* Auto adjust ? */
  111.    char backdrop[256];
  112.    char pub[139];
  113.     char accent[256];        /* Language file for tRanslate */
  114.     char tkey[100];
  115.     char hkey[100];
  116.  
  117.     struct Event events[11];  /* For the alarm! */ 
  118. }prefs;
  119.  
  120. struct {
  121. /* Time structure, set up by gettime() and used globally */
  122.  
  123.    int hours;        /* Number of hours since midnight on system clock */
  124.    int seconds;      /* Number of seconds */
  125.    int minutes;      /* Number of minutes */
  126.    int years;        /* Current year */
  127.    int days;         /* Date in current month */
  128.    int months;       /* Current month */
  129.    int wday;         /* Day in the week 0-6 (starting Sunday) */
  130. }time;
  131.  
  132.  
  133. struct {
  134. /* Font structure, set up by getfont() and used globally */
  135.  
  136.    int x;            /* Width of default graphic font */
  137.    int y;            /* Height of default graphic font */
  138. }font;
  139.  
  140. struct IntuiMessage *message;   /* Set up our message pointer */
  141. extern struct ExecBase *SysBase;
  142. struct timerequest *TimerIO=NULL;
  143. struct Library *TimerBase=NULL;
  144.  
  145. /* Following for screen information routine */
  146. #include "EngClock_Screen.h"
  147.  
  148.    int exit_flag=0;
  149.    struct Window *win_p;  /* Our window pointer */
  150.    struct NewWindow win1;  /* Window structure - assigned later */
  151.  
  152.    /* IntuiText definitions */
  153.  
  154.    /* Main IntuiText for the window text */
  155.  
  156.    struct IntuiText int_text= {
  157.       1,0,JAM1,16,9,NULL,NULL,NULL };
  158.    struct IntuiText date_text = {
  159.       1,0,JAM1,16,19,NULL,NULL,NULL };
  160.  
  161.     struct IntuiText req_text= {
  162.       1,0,JAM1,16,9,NULL,NULL,NULL };
  163.  
  164.    
  165.    struct IntuiText ok_text={
  166.       1,0,JAM1,16,9,NULL,NULL,NULL };
  167.  
  168. /* Menu definitions and structure follow... */
  169.  
  170.    /* First the IntuiText strings for each menu item */
  171.  
  172.    struct IntuiText menu_text1 = {
  173.       2,0,JAM1,0,1,NULL,"Set Prefs...",NULL };
  174.    struct IntuiText menu_text2 = {
  175.       2,0,JAM1,0,1,NULL,"Jump",NULL };
  176.    struct IntuiText menu_text3 = {
  177.       2,0,JAM1,0,1,NULL,"About",NULL };
  178.    struct IntuiText menu_text4 = {
  179.       2,0,JAM1,0,1,NULL,"Quit",NULL };
  180.  
  181.    /* And now the menu bits (in reverse order) */
  182.  
  183.  
  184.    struct MenuItem menu_item4 = {
  185.       NULL,0,30,150,10,ITEMTEXT|
  186.                      ITEMENABLED|
  187.                      COMMSEQ|
  188.                      HIGHCOMP, 0x00000001,(APTR)&menu_text4,NULL,'Q',NULL,
  189.                      MENUNULL,};
  190.    struct MenuItem menu_item3 = {
  191.       &menu_item4,0,20,150,10,ITEMTEXT|
  192.                        ITEMENABLED|
  193.                        HIGHCOMP|
  194.                        COMMSEQ,0x00000001,(APTR) &menu_text3,NULL,'A',NULL,
  195.                        MENUNULL,};
  196.    struct MenuItem menu_item2 = {
  197.       &menu_item3,0,10,150,10,ITEMTEXT|
  198.                        ITEMENABLED|
  199.                        COMMSEQ|
  200.                        HIGHCOMP,0x00000001,(APTR) &menu_text2,NULL,'J',NULL,
  201.                        MENUNULL,};
  202.    struct MenuItem menu_item1 = {
  203.       &menu_item2,0,0,150,10,ITEMTEXT|
  204.                        ITEMENABLED|
  205.                        COMMSEQ|
  206.                        HIGHCOMP,0x00000001,(APTR) &menu_text1,NULL,'S',NULL,
  207.                        MENUNULL,};
  208.    
  209.    /* Finally the menus themselves */
  210.  
  211.    struct Menu menu1 = {
  212.       NULL,0,0,70,0,MENUENABLED,"Project",&menu_item1 };
  213.  
  214.  
  215. /* Global pointers for data used in date */
  216.  
  217. char *months_data[13] = {
  218.    "",
  219.    "January",
  220.    "February",
  221.    "March",
  222.    "April",
  223.    "May",
  224.    "June",
  225.    "July",
  226.    "August",
  227.    "September",
  228.    "October",
  229.    "November",
  230.    "December"
  231. };
  232.  
  233. char *months_data_french[13] = {
  234.    "",
  235.    "Janvier",
  236.    "Février",
  237.    "Mars",
  238.    "Avril",
  239.    "Mai",
  240.    "Juin",
  241.    "Juillet",
  242.    "Août",
  243.    "Septembre",
  244.    "Octobre",
  245.    "Novembre",
  246.    "Décembre"
  247. };
  248.  
  249. char *months_data_spanish[13]={
  250.     "",
  251.     "enero",
  252.     "febrero",
  253.     "marzo",
  254.     "abril",
  255.     "mayo",
  256.     "junio",
  257.     "julio",
  258.     "agosto",
  259.     "septiembre",
  260.     "octubre",
  261.     "noviembre",
  262.     "diciembre"
  263. };
  264.  
  265. char *days_data[7] = {
  266.    "Sunday",
  267.    "Monday",
  268.    "Tuesday",
  269.    "Wednesday",
  270.    "Thursday",
  271.    "Friday",
  272.    "Saturday"
  273. };
  274.  
  275. char *days_data_french[7] = {
  276.    "Dimanche",
  277.    "Lundi",
  278.    "Mardi",
  279.    "Mercredi",
  280.    "Jeudi",
  281.    "Vendredi",
  282.    "Samedi"
  283. };
  284.  
  285. char *days_data_spanish[7] = {
  286.     "Domingo",
  287.     "Lunes",
  288.     "Martes",
  289.     "Miércoles",
  290.     "Jueves",
  291.     "Viernes",
  292.     "Sábado"
  293. };
  294.  
  295. BOOL Wb;  /* Workbench (TRUE) or CLI (FALSE) */
  296. struct WBStartup *Wbs;
  297.  
  298. /* Stuff for backdrops */
  299.  
  300. struct Picture
  301. {
  302.    struct BitMapHeader bmhd;  /* format and infos */
  303.    struct BitMap *bmap;       /* bitmap */
  304.    ULONG *palette;            /* color table in LoadRGB32() format */
  305.    LONG palette_size;         /* mem usage */
  306.    LONG palette_entries;      /* number of colors */
  307.    ULONG display_ID;          /* video mode */
  308.    UBYTE *author;             /* author info */
  309.    UBYTE *copyright;          /* copyright info */
  310.    UBYTE *annotation;         /* other info */
  311.    LONG author_size;          /* mem usage */
  312.    LONG copyright_size;       /* mem usage */
  313.    LONG annotation_size;      /* mem usage */
  314. };
  315.  
  316. struct Picture piccy;
  317. BOOL ispicture=FALSE;
  318.  
  319. struct TextAttr about_font = {
  320.     NULL,
  321.     NULL,
  322.     FSF_UNDERLINED,
  323.     NULL
  324. };
  325.  
  326. /* Special access variables */
  327.  
  328. extern struct MsgPort *CxMsgPort;
  329. extern struct MsgPort *CxHotKey1;
  330. extern struct MsgPort *CxHotKey2;
  331. extern struct MsgPort *RexxPort;
  332.  
  333. extern CxMsg *CxMessage;
  334.  
  335. /* Lib bases */
  336.  
  337. struct IntuitionBase *IntuitionBase=NULL;
  338. struct GfxBase *GfxBase=NULL;
  339. struct Library *UtilityBase=NULL;
  340. struct Library *GadToolsBase=NULL;
  341. struct Library *DiskfontBase=NULL;
  342. struct Library *CxBase=NULL;
  343. struct Library *TranslatorBase=NULL;
  344. struct Library *AslBase=NULL;
  345. struct Library *IFFParseBase=NULL;
  346. struct Library *DataTypesBase=NULL;
  347. struct Library *RexxSysBase=NULL;
  348.  
  349. extern struct Library *DOSBase;
  350.  
  351.  
  352.  
  353. /********* Prototypes ************/
  354.  
  355. short main(int argc, char *argv[]);
  356. void gettime(void);
  357. short readprefs(void);
  358. void  setupengnums(void);
  359. void  openall(void);
  360. void  closeall(void);
  361. void  getfont(void);
  362. void  clearwindow(void);
  363. short setupmainwindow(void);
  364. short changemenu(void);
  365. short refreshwindow(void);
  366. void setupdate_english(void);
  367. void setupdate_french(void);
  368. void setupdate_spanish(void);
  369.  
  370.  
  371. extern void process_alarm(void);
  372. extern BOOL talk(char *text);
  373. extern int prefsgui(void);
  374. extern BOOL jump(void);
  375. extern short getlocale(void);
  376. extern char *trans(char *text);
  377. extern char *findday(int preset2);
  378. extern char datey[200];
  379. extern BOOL playsam(char *esvxname);
  380. extern void msg(char *msg);
  381. extern BOOL loadpic(char *fname, struct Screen *scr);
  382. extern void pattern(struct Window *win_p, struct Screen *scr,struct Picture pic);
  383. extern void unloadpic(struct Picture pic);
  384. extern BOOL cxinit(void);
  385. extern void cxclose(void);
  386. extern BOOL wb_ask(char *body, char *opt1, char *opt2);
  387. extern void autoadjust(void);
  388. extern void arexxclose(void);
  389. extern void process_arexx(void);
  390. extern BOOL arexxinit(void);
  391. extern BOOL about(void);
  392. extern void process_args(int count, char *args[]);